import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'todo_page_final.dart';

class startUpPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    get(context);
        return Swiper(
            itemCount: 3,
            loop: false,
            itemBuilder: (BuildContext context, int index) {
              return new Image.asset(
                'assets/banner/banner-${index + 1}.jpg',
                fit: BoxFit.fill,
              );
            },
            pagination: new SwiperPagination(),
            onTap: (int index){
              if(index == 2)
              {
//                print("i am used");
                set();
                Navigator.of(context).pushAndRemoveUntil(
                    new MaterialPageRoute(builder: (context) => new TodoPageFinal()
                    ), (route) => route == null);
              }
            });

  }
  set() async{
    SharedPreferences preferences = await SharedPreferences.getInstance();
    String account = 'false';
    preferences.setString('_showbanner', account);
    //print('存储_showbanner为:$account');
  }
  get(BuildContext context) async{
    SharedPreferences prefs = await SharedPreferences.getInstance();
    String showBanner = prefs.getString('_showbanner');
    //print('get到了_showBanner为$showBanner');
    showBanner != 'false' ? {} : push(context);
  }
  push(BuildContext context){
    Navigator.of(context).pushAndRemoveUntil(
        new MaterialPageRoute(builder: (context) => new TodoPageFinal()
        ), (route) => route == null);
  }
}
